#!/bin/bash
set -ex

DOCKER_IMAGE=${DOCKER_REPO/#index.docker.io\/}

docker image build \
    --build-arg VCS_REF="$GIT_SHA1" \
    --build-arg BUILD_DATE="$(date --rfc-3339 ns)" \
    --build-arg DOCKER_IMAGE="$DOCKER_IMAGE" \
    --build-arg BASE_IMAGE_REPO="$BASE_IMAGE_REPO" \
    --build-arg BASE_IMAGE_TAG="$DOCKER_TAG" \
    --build-arg SAAS_PROVIDER_URL="$SAAS_PROVIDER_URL" \
    --build-arg SAAS_PROVIDER_TOKEN="$SAAS_PROVIDER_TOKEN" \
    --build-arg GITHUB_USER="$GITHUB_USER" \
    --build-arg GITHUB_TOKEN="$GITHUB_TOKEN" \
    --build-arg GITHUB_BOT_TOKEN="$GITHUB_BOT_TOKEN" \
    --tag "$DOCKER_REPO:$DOCKER_TAG" \
    .
